﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SQLite;
using TestMatrix.Model;

namespace TestMatrix.DataModel.Factory
{
    public class SQLiteDataSourceItem : IDataSourceItem
    {
        private SQLiteConnection _dbConn;

        public SQLiteDataSourceItem(SQLiteConnection dbConn)
        {
            this._dbConn = dbConn;
        }

        public object GetDataSource()
        {
            return this._dbConn;
        }

        #region tblETLHistory
        public List<tblETLHistory> QueryTblETLHistory(string sql)
        {
            return _dbConn.Query<tblETLHistory>(sql);
        }
        #endregion

        #region tblBugList

        public List<tblBugList> QueryTblBugList(string sql)
        {
            return _dbConn.Query<tblBugList>(sql);
        }

        public List<tblBugList> QueryTblBugList(string sql, params string[] args)
        {
            return _dbConn.Query<tblBugList>(sql, args);
        }

        public void InsertBugs(tblBugList bugs)
        {
            _dbConn.Insert(bugs);
        }


        public void InsertAllBugs(List<tblBugList> bugs)
        {
            _dbConn.InsertAll(bugs);
        }

        public void DeleteAllBugs()
        {
            _dbConn.DeleteAll<tblBugList>();
        }

        #endregion


        #region tblNumOfCreatedTC

        public List<tblNumOfCreatedTC> QueryTblNumOfCreatedTC(string sql)
        {
            return _dbConn.Query<tblNumOfCreatedTC>(sql);
        }

        public List<tblNumOfCreatedTC> QueryTblNumOfCreatedTC(string sql, params string[] args)
        {
            return _dbConn.Query<tblNumOfCreatedTC>(sql, args);
        }

        public void InsertTblNumOfCreatedTC(tblNumOfCreatedTC tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAllTblNumOfCreatedTC()
        {
            _dbConn.DeleteAll<tblNumOfCreatedTC>();
        }

        #endregion

        #region tblTestAutomation

        public List<tblTestAutomation> QueryTblTestAutomation(string sql)
        {
            return _dbConn.Query<tblTestAutomation>(sql);
        }

        public List<tblTestAutomation> QueryTblTestAutomation(string sql, params string[] args)
        {
            return _dbConn.Query<tblTestAutomation>(sql, args);
        }

        public void InsertTblTestAutomation(tblTestAutomation tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAllTblTestAutomation()
        {
            _dbConn.DeleteAll<tblTestAutomation>();
        }

        #endregion

        #region tblNumOfExecutedTC

        public List<tblNumOfExecutedTC> QuerytblNumOfExecutedTC(string sql)
        {
            return _dbConn.Query<tblNumOfExecutedTC>(sql);
        }

        public List<tblNumOfExecutedTC> QuerytblNumOfExecutedTC(string sql, params string[] args)
        {
            return _dbConn.Query<tblNumOfExecutedTC>(sql, args);
        }

        public void InserttblNumOfExecutedTC(tblNumOfExecutedTC tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAlltblNumOfExecutedTC()
        {
            _dbConn.DeleteAll<tblNumOfExecutedTC>();
        }

        #endregion

        #region tblReleaseInfo

        public List<tblReleaseInfo> QuerytblReleaseInfo(string sql)
        {
            return _dbConn.Query<tblReleaseInfo>(sql);
        }

        public List<tblReleaseInfo> QuerytblReleaseInfo(string sql, params string[] args)
        {
            return _dbConn.Query<tblReleaseInfo>(sql, args);
        }

        public void InserttblReleaseInfo(tblReleaseInfo tc)
        {
            _dbConn.Insert(tc);
        }

        public void InsertAlltblReleaseInfo(List<tblReleaseInfo> tc)
        {
            _dbConn.InsertAll(tc);
        }

        public void DeleteAlltblReleaseInfo()
        {
            _dbConn.DeleteAll<tblReleaseInfo>();
        }

        public void UpdatetblReleaseInfo(tblReleaseInfo tc)
        {
            _dbConn.Update(tc);
        }

        
        #endregion

        #region tblReleaseDetailInfo

        public List<tblReleaseDetailInfo> QuerytblReleaseDetailInfo(string sql)
        {
            return _dbConn.Query<tblReleaseDetailInfo>(sql);
        }

        public List<tblReleaseDetailInfo> QuerytblReleaseDetailInfo(string sql, params string[] args)
        {
            return _dbConn.Query<tblReleaseDetailInfo>(sql, args);
        }

        public void InserttblReleaseDetailInfo(tblReleaseDetailInfo tc)
        {
            _dbConn.Insert(tc);
        }

        public void InsertAlltblReleaseDetailInfo(List<tblReleaseDetailInfo> tc)
        {
            _dbConn.InsertAll(tc);
        }

        public void DeleteAlltblReleaseDetailInfo()
        {
            _dbConn.DeleteAll<tblReleaseDetailInfo>();
        }

        public void UpdatetblReleaseDetailInfo(tblReleaseDetailInfo tc)
        {
            _dbConn.Update(tc);
        }


        #endregion

        #region tblTestCaseInCI

        public List<tblTestCaseInCI> QuerytblTestCaseInCI(string sql)
        {
            return _dbConn.Query<tblTestCaseInCI>(sql);
        }

        public List<tblTestCaseInCI> QuerytblTestCaseInCI(string sql, params string[] args)
        {
            return _dbConn.Query<tblTestCaseInCI>(sql, args);
        }

        public void InserttblTestCaseInCI(tblTestCaseInCI tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAlltblTestCaseInCI()
        {
            _dbConn.DeleteAll<tblTestCaseInCI>();
        }
        #endregion

        #region tblGolbalTestCasePassRate

        public List<tblGlobalTestCasePassRate> QuerytblGolbalTestCasePassRate(string sql)
        {
            return _dbConn.Query<tblGlobalTestCasePassRate>(sql);
        }

        public List<tblGlobalTestCasePassRate> QuerytblGolbalTestCasePassRate(string sql, params string[] args)
        {
            return _dbConn.Query<tblGlobalTestCasePassRate>(sql, args);
        }

        public void InserttblGolbalTestCasePassRate(tblGlobalTestCasePassRate tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAlltblGolbalTestCasePassRate()
        {
            _dbConn.DeleteAll<tblGlobalTestCasePassRate>();
        }
        #endregion


        #region tblGlobalTestCaseAutomation

        public List<tblGlobalTestCaseAutomation> QuerytblGlobalTestCaseAutomation(string sql)
        {
            return _dbConn.Query<tblGlobalTestCaseAutomation>(sql);
        }

        public List<tblGlobalTestCaseAutomation> QuerytblGlobalTestCaseAutomation(string sql, params string[] args)
        {
            return _dbConn.Query<tblGlobalTestCaseAutomation>(sql, args);
        }

        public void InserttblGlobalTestCaseAutomation(tblGlobalTestCaseAutomation tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAlltblGlobalTestCaseAutomation()
        {
            _dbConn.DeleteAll<tblGlobalTestCaseAutomation>();
        }
        #endregion

        #region tblGlobalDRE

        public List<tblGlobalDRE> QuerytblGlobalDRE(string sql)
        {
            return _dbConn.Query<tblGlobalDRE>(sql);
        }

        public List<tblGlobalDRE> QuerytblGlobalDRE(string sql, params string[] args)
        {
            return _dbConn.Query<tblGlobalDRE>(sql, args);
        }

        public void InserttblGlobalDRE(tblGlobalDRE tc)
        {
            _dbConn.Insert(tc);
        }

        public void DeleteAlltblGlobalDRE()
        {
            _dbConn.DeleteAll<tblGlobalDRE>();
        }
        #endregion
    }
}
